-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE PaModificarMaquina
    @IdMaquina int,
    @NombreMaquina varchar(80),
	@NumeroSerie   varchar(20),
	@NumeroMaquina   int,
	@Imagen image,
	@Estado  char,
	@IndicacionesUso varchar(255),
	@TipoMaquina int
AS
BEGIN
	SET NOCOUNT ON;
	BEGIN TRY
		
		BEGIN TRAN
			
			UPDATE [dbo].[Maquinas]
   SET [NombreMaquina] = @NombreMaquina
      ,[NumeroSerie] = @NumeroSerie
      ,[NumeroMaquina] = @NumeroMaquina
      ,[FotoMaquina] = @Imagen
      ,[IndicacionesUso] = @IndicacionesUso
      ,[Estado] = @Estado
      ,[IdTipoMaquina] = @TipoMaquina
 WHERE IdMaquina = @IdMaquina
		
		COMMIT TRAN

	END TRY
	BEGIN CATCH
		
		DECLARE @ErrorMessage NVARCHAR(4000);
		DECLARE @ErrorSeverity INT;
		DECLARE @ErrorState INT;

		SELECT 
			@ErrorMessage = ERROR_MESSAGE(),
			@ErrorSeverity = ERROR_SEVERITY(),
			@ErrorState = ERROR_STATE();

		RAISERROR (@ErrorMessage, -- Message text.
				   @ErrorSeverity, -- Severity.
				   @ErrorState -- State.
				   );
		
		IF(@@TRANCOUNT>0)
			ROLLBACK TRAN
		
	END CATCH;
END

